<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateActivity extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('activity',['id'=>false,'comment'=>'招商活动','collation'=>'utf8mb4_general_ci']);
        $table->addColumn('id','biginteger',['limit'=>20,'identity'=>true,'signed'=>false])
            ->setPrimaryKey('id')
            ->addColumn('buyin_activity_id','biginteger',['limit'=>20,'default'=>0,'comment'=>'巨量百应活动id','signed'=>false])
            ->addColumn('uid','biginteger',['limit'=>20,'default'=>0,'comment'=>'业务员用户ID','signed'=>false])
            ->addColumn('activity_kind','boolean',['limit'=>1,'default'=>0,'comment'=>'活动类型 0专属招商 1公开招商','signed'=>false])
            ->addColumn('activity_type','boolean',['limit'=>1,'default'=>1,'comment'=>'招商方式 1全部商家 2指定商家','signed'=>false])
            ->addColumn('activity_name','string',['limit'=>60,'comment'=>'活动标题'])
            ->addColumn('activity_desc','string',['limit'=>200,'comment'=>'活动要求'])
            ->addColumn('apply_start_time','biginteger',['limit'=>13,'signed'=>false,'comment'=>'报名开始时间'])
            ->addColumn('apply_end_time','biginteger',['limit'=>13,'signed'=>false,'comment'=>'报名结束时间'])
            ->addColumn('promote_start_time','biginteger',['limit'=>13,'signed'=>false,'comment'=>'推广开始时间'])
            ->addColumn('promote_end_time','biginteger',['limit'=>13,'signed'=>false,'comment'=>'推广结束时间'])
            ->addColumn('category','string',['comment'=>'商品分类','limit'=>1500])
            ->addColumn('commission_rate','integer',['limit'=>3,'comment'=>'佣金率(不低于)','signed'=>false])
            ->addColumn('service_rate','integer',['limit'=>3,'comment'=>'服务费率','signed'=>false])
            ->addColumn('estimated_single_sale','decimal',['precision'=>10,'scale'=>2,'comment'=>'预估单品成交金额','signed'=>false])
            ->addColumn('wechat_id','string',['limit'=>32,'comment'=>'微信号'])
            ->addColumn('phone_num','string',['limit'=>11,'comment'=>'手机号'])
            ->addColumn('online','boolean',['limit'=>1,'default'=>0,'comment'=>'是否上线 0未上线 1上线','signed'=>false])
           // ->addColumn('specified_shop_ids','string',['limit'=>600,'comment'=>'指定商家信息','default'=>'[]'])
            ->addColumn('apply_num','integer',['limit'=>10,'default'=>0,'comment'=>'已报名数','signed'=>false])
            ->addColumn('un_audit_num','integer',['limit'=>10,'default'=>0,'comment'=>'待审核数','signed'=>false])
        //    ->addColumn('status','boolean',['limit'=>1,'comment'=>'状态 1未上线 2报名未开始 3报名中 4 推广未开始 5推广中 6已结束'])
            ->addIndex('buyin_activity_id')
            ->addColumn('create_time','datetime',['comment'=>'创建时间'])
            ->addColumn('update_time','datetime',['comment'=>'更新时间'])
            ->create();
    }
}
